package com.shenyi.mould.rest.controller.wx;

import com.shenyi.core.utils.R;
import com.shenyi.wx.annotation.IgnoreAuth;
import com.shenyi.wx.annotation.LoginUser;
import com.shenyi.wx.api.IApiUserService;
import com.shenyi.wx.entity.UserDO;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author richard.fan
 * @version 1.0
 * @date 2018/11/07
 * @desc 测试
 * @see
 * @since 1.0
 */
@Api(tags = "测试接口")
@RestController
@RequestMapping("/api/test")
public class ApiTestController {

    @Autowired
    private IApiUserService userService;

    /**
     * 获取用户信息
     */
    @GetMapping("userInfo")
    public R userInfo(@LoginUser UserDO user) {
        return R.ok().put("user", user);
    }

    /**
     * 忽略Token验证测试
     */
    @IgnoreAuth
    @GetMapping("notToken")
    public R notToken() {
        return R.ok().put("msg", "无需token也能访问。。。");
    }

    /**
     * 根据手机号查询用户信息接口测试方法
     *
     * @param mobile
     * @return
     */
    @IgnoreAuth
    @GetMapping("userListByMobile")
    public R userList(String mobile) {
        UserDO userEntity = userService.queryByMobile(mobile);
        return R.ok().put("dto", userEntity);
    }
}
